package com.gzc.just.play.last.war.sceneserver.damage;

/**
 * 伤害类型枚举
 * 
 * @author AI Assistant
 * @version 1.0.0
 * @since 2025-11-22
 */
public enum DamageType {
    PHYSICAL(1, "物理伤害", 1.0f),      // 物理伤害
    MAGICAL(2, "魔法伤害", 1.0f),       // 魔法伤害
    PURE(3, "纯伤害", 1.0f),            // 纯伤害（无法被防御）
    HEAL(4, "治疗", 1.0f),              // 治疗（特殊的负伤害）
    TRUE_DAMAGE(5, "真实伤害", 1.0f),   // 真实伤害（类似纯伤害）
    POISON(6, "毒伤", 1.0f),            // 毒伤（持续伤害）
    BURN(7, "灼烧", 1.0f),              // 灼烧伤害（持续伤害）
    BLEED(8, "流血", 1.0f),             // 流血伤害（持续伤害）
    UNKNOWN(0, "未知伤害", 1.0f);       // 未知伤害

    private final int code;             // 伤害类型编码
    private final String name;          // 伤害类型名称
    private final float damageMultiplier; // 伤害倍数

    DamageType(int code, String name, float damageMultiplier) {
        this.code = code;
        this.name = name;
        this.damageMultiplier = damageMultiplier;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public float getDamageMultiplier() {
        return damageMultiplier;
    }

    /**
     * 是否可以被防御
     */
    public boolean canBeDefended() {
        return this == PHYSICAL || this == MAGICAL;
    }

    /**
     * 是否是持续伤害
     */
    public boolean isDOT() {
        return this == POISON || this == BURN || this == BLEED;
    }

    /**
     * 根据编码获取伤害类型
     */
    public static DamageType fromCode(int code) {
        for (DamageType type : DamageType.values()) {
            if (type.code == code) {
                return type;
            }
        }
        return UNKNOWN;
    }
}
